package com.bwie.task;

import cn.hutool.core.util.StrUtil;
import com.bwie.domain.TbRedEnvelope;
import com.bwie.es.TbRedEnvelopeEs;
import com.bwie.mapper.TbRedEnvelopeMapper;
import com.bwie.service.TbRedEnvelopeService;
import io.reactivex.rxjava3.annotations.SchedulerSupport;
import lombok.extern.slf4j.Slf4j;
import org.apache.lucene.search.TopDocs;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate;
import org.springframework.data.elasticsearch.core.IndexOperations;
import org.springframework.data.elasticsearch.core.document.Document;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.scheduling.annotation.Schedules;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * description:
 *
 * @Author youhongwei
 * @Create 2025/6/17 16:53
 * @Version 1.0
 */
@Slf4j
@Component
public class MyTest {

    @Autowired
    private TbRedEnvelopeMapper tbRedEnvelopeMapper;

    @Autowired
    private ElasticsearchRestTemplate elasticsearchRestTemplate;

    @SchedulerSupport("0 0/10 * * *")
    public void init(){
        IndexOperations indexOperations = elasticsearchRestTemplate.indexOps(TbRedEnvelopeEs.class);
        boolean exists = indexOperations.exists();
        if(!exists){
            indexOperations.create();

            Document mapping = indexOperations.createMapping();
            indexOperations.putMapping(mapping);
        }
        List<TbRedEnvelope> list = tbRedEnvelopeMapper.selectList(null);
        for (TbRedEnvelope tbRedEnvelope : list) {

        }
    }


}
